/*
 * Copyright (C) 2021 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.florent37.github.com.expansionpanel.slice;

import com.florent37.github.com.expansionpanel.ExpansionHeader;
import com.florent37.github.com.expansionpanel.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Component;
import ohos.agp.components.ComponentContainer;

/**
 * lipeiquan
 *
 * @since 2021-05-06
 */
public class ExpansionPanelSampleAbilitySlice extends AbilitySlice {
    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_expansion_panel_sample);
        ComponentContainer idDirlContainer = (ComponentContainer) findComponentById(ResourceTable.Id_dirl_container);
        int childCount = idDirlContainer.getChildCount();
        for (int i = 0; i < childCount; i++) {
            Component componentAt = idDirlContainer.getComponentAt(i);
            if (componentAt instanceof ComponentContainer) {
                ComponentContainer cp = (ComponentContainer) componentAt;
                int childCount1 = cp.getChildCount();
                for (int j = 0; j < childCount1; j++) {
                    Component cpView = cp.getComponentAt(j);
                    if (cpView instanceof ExpansionHeader) {
                        ((ExpansionHeader) cpView).init(ResourceTable.Id_expansionLayout, true, ResourceTable.Id_headerIndicator, 0, 0);
                    }
                }
            }
        }
    }

    @Override
    public void onActive() {
        super.onActive();
    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }
}
